package io.github.maojian.temp;

import org.junit.Test;

import java.util.*;

/**
 * @Auther: jian.mao
 * @Date: 2022/6/14 09:26
 * @Description:
 */
public class Demo {

    @Test
    public void test01() {
        Map<String, Object> stringObjectMap = new HashMap<>();
        String string = "key";

        //三目运算符 运算优先级
        System.out.println((string + ":" + stringObjectMap.get(string)) == null ? "" : stringObjectMap.get(string).toString());

        System.out.println("x:" + ("a".equals("a") ? "" : "xx"));
    }

    @Test
    public void test02() {
        Map<String, Object> map = new HashMap<>();
        String s = (String) map.get("test");
        System.out.println(s);
    }

    @Test
    public void test03() {
        Map<String, String> map = new HashMap<>();
        map.put("test01", "");

        Map<String, String> map01 = new HashMap<>();
        map = map01;
        System.out.println(map.get("test01"));
    }

    @Test
    public void test04() {
        String s = new String("test");
        s.intern();
    }

    @Test
    public void test05() {
        List<String> list = new ArrayList<>();
        String s = "1";
        list.add(s);
        list.add(s);
        list.stream().forEach(System.out::println);
    }

    /**
     * 测试队列api
     */
    @Test
    public void test06() {
        Queue queue = new ArrayDeque();
        queue.offer(1);
        queue.poll();
        queue.peek();
        queue.size();
        queue.poll();
        queue.add(2);
        queue.remove();
        queue.addAll(null);
    }

    @Test
    public void test07() {
        String s = "a";
        System.out.println(s.substring(0, 1));
    }

    @Test
    public void test() {
        String isRecord = "1";
        String balanceType = "0";
        if (("0".equals(balanceType) || "1".equals(balanceType)) && "1".equals(isRecord)) {
            System.out.println("111");
        }
    }

    @Test
    public void test08(){
        int i = 50;
        int s = i++;
        int k = i++*2;
        System.out.println(i);
        System.out.println(s);
        System.out.println(k);
    }
}
